//-----------------------------------------------------------------------
// <copyright file="CommentService.cs" company="FetCo">
//     Copyright (c) FetCo. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------	

using System;
using System.Collections;
using FetCo.Framework;
using ADESSA.Entities;
using ADESSA.Data;
    
namespace ADESSA.Business
{   
	/// <summary>
	/// 
	/// </summary> 
    public class CommentService
    {
        #region Comment

        public static void CreateComment(Comment comment)
        {            
            try
            {
                CommentDAO commentDAO = new CommentDAO();
                commentDAO.CreateComment(comment);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessCreateCommentException, ex);
            }
        }        

        public static void UpdateComment(Comment comment)
        {            
            try
            {
                CommentDAO commentDAO = new CommentDAO();
                commentDAO.UpdateComment(comment);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessUpdateCommentException, ex);
            }
        }        

        public static void DeleteComment(long commentId)
        {            
            try
            {
                CommentDAO commentDAO = new CommentDAO();
                commentDAO.DeleteComment(commentId);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessDeleteCommentException, ex);
            }
        }
        
        public static Comment GetComment(long commentId)
        {            
            try
            {
                CommentDAO commentDAO = new CommentDAO();
                return commentDAO.GetComment(commentId);                
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetCommentException, ex);
            }
        }                

        public static CommentCollection GetCommentList(CommentColumns orderBy, OrderDirection orderDirection)
        {            
            try
            {
                CommentDAO commentDAO = new CommentDAO();
                return commentDAO.GetCommentList(orderBy, orderDirection);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetCommentListException, ex);
            }
        }        

        public static CommentCollection GetCommentList(CommentColumns orderBy, OrderDirection orderDirection, int page, int pageSize, out int totalRecords)
        {            
            try
            {
                CommentDAO commentDAO = new CommentDAO();
                return commentDAO.GetCommentList(orderBy, orderDirection, page, pageSize, out totalRecords);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetCommentListException, ex);
            }
        }        

	    public static CommentCollection GetCommentListByParam(object orderBy, OrderDirection orderDirection,string where)
        {            
            try
            {
                CommentDAO commentDAO = new CommentDAO();
                return commentDAO.GetCommentListByParam(orderBy, orderDirection,where);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetCommentListException, ex);
            }
        }        

        public static CommentCollection GetCommentListByParam(object orderBy, OrderDirection orderDirection, int page, int pageSize,string Criteria, out int totalRecords)
        {            
            try
            {
                CommentDAO commentDAO = new CommentDAO();
                return commentDAO.GetCommentListByParam(orderBy, orderDirection, page, pageSize,Criteria, out totalRecords);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetCommentListException, ex);
            }
        }        

        #endregion
    }
}